#include <windows.h>
#include "osal_keys.h"

#ifdef __cplusplus
extern "C" {
#endif

static const unsigned char WIN_HID_TO_NATIVE[256] = {
255,255,255,255, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 49, 50,
 51, 52, 53, 54, 55, 56, 57, 48, 13, 27,  8,  9, 32,189,187,219,
221,220,255,186,222,192,188,190,191, 20,112,113,114,115,116,117,
118,119,120,121,122,123, 44,145, 19, 45, 36, 33, 46, 35, 34, 39,
 37, 40, 38,144,111,106,109,107,255, 97, 98, 99,100,101,102,103,
104,105, 96,110,255,255,255,255,124,125,126,127,128,129,130,131,
132,133,134,135,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
 17, 16, 18,255,255,255,255,255,255,  1,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
};

EXPORT void CALL osal_keys_init()
{
}

EXPORT void CALL osal_keys_quit()
{
}

EXPORT void CALL osal_keys_update_state()
{
}

EXPORT unsigned int CALL osal_is_key_pressed(unsigned int _key, unsigned int _mask)
{
	if (_key == 0 || _key > 255)
		return 0;
	return GetAsyncKeyState(WIN_HID_TO_NATIVE[_key]) & _mask;
}

#ifdef __cplusplus
}
#endif
